package logic

import (
	"ball/ballrpc/ballrpc"
	"ball/ballrpc/internal/svc"
	"ball/models/mysql"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type TalkAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTalkAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TalkAddLogic {
	return &TalkAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 创建谈论分类
func (l *TalkAddLogic) TalkAdd(in *ballrpc.TalkAddRequest) (*ballrpc.TalkAddResponse, error) {
	// todo: add your logic here and delete this line
	talk := mysql.Talk{
		Image: in.Image,
		Name:  in.Name,
		Price: in.Price,
	}
	mysql.DB.Debug().Create(&talk)
	return &ballrpc.TalkAddResponse{
		Id: int64(talk.ID),
	}, nil
}
